package bgw

import (
	"math"

	"github.com/spf13/cast"
)

type WithdrawRequest struct {
	OuterNo     string `json:"outerNo"`
	UserId      string `json:"userId"`
	Currency    int64  `json:"currency"`
	Amount      int64  `json:"amount"`
	Scale       int64  `json:"scale"`
	Address     string `json:"address"`
	NotifyURL   string `json:"notifyURL"`
	Extend      string `json:"extend"`
	Subject     string `json:"subject"`
	Description string `json:"description"`
	Nickname    string `json:"nickname"`
	Avatar      string `json:"avatar"`
}

func (w *WithdrawRequest) calAmount() {
	w.Amount = w.Amount * cast.ToInt64(math.Pow(10, cast.ToFloat64(w.Scale)))
}

type WithdrawCallbackRequest struct {
	OrderNo       string `json:"orderNo"`
	OuterNo       string `json:"outerNo"`
	AppId         int64  `json:"appId"`
	CurrencyId    int64  `json:"currencyId"`
	Amount        int64  `json:"amount"` // 提现金额，实际值由精度值scale决定，如 scale=2 时，1000 表示 10
	Commission    int64  `json:"commission"`
	Scale         int64  `json:"scale"`
	Type          int64  `json:"type"`
	Status        int64  `json:"status"`
	IsTest        bool   `json:"isTest"`
	CurrencyName  string `json:"currencyName"`
	CreateTime    int64  `json:"createTime"`
	ConfirmTime   int64  `json:"confirmTime"`
	RejectTime    int64  `json:"rejectTime"`
	RejectReason  string `json:"rejectReason"`
	Extend        string `json:"extend"`
	TransactionId string `json:"transactionId"`
}

func (w *WithdrawCallbackRequest) calAmount() {
	w.Amount = cast.ToInt64(cast.ToFloat64(w.Amount) / math.Pow(10, cast.ToFloat64(w.Scale)))
}

type PaymentReq struct {
	OuterNo   string `json:"outerNo"`
	UserId    string `json:"userId"`
	Currency  int64  `json:"currency"`
	Amount    int64  `json:"amount"`
	Scale     int64  `json:"scale"`
	NotifyUrl string `json:"notifyURL"`
}
